// pages/live/live.js
var app = getApp()
import {adapi, appnavapi} from "../../utils/api"
import utils from "../../utils/util"

Page({

    /**
     * 页面的初始数据
     */
    data: {
        openid: "",
        livedata: "",
        adList: [
            {
                cover: "https://p9-pc-sign.douyinpic.com/tos-cn-p-0015/f06c3a53039a413487e79e258ea8e6a8_1621939217~tplv-dy-360p.jpeg?biz_tag=pcweb_cover&from=3213915784&s=PackSourceEnum_SEARCH&sc=origin_cover&se=false&x-expires=1693184400&x-signature=42ZvoTA60KaaNVme84hSZ%2FTddhk%3D",
                create_time: 1691715812,
                id: 1,
                mch_id: 62,
                name: "全面招商，合作共赢｜一起向未来",
                num1: 333333333,
                num2: 2222222,
                num3: 111111,
                status: 1,
                update_time: 1691715812,
                url: "http://v215jpgmvftx6vc66opvvc92w9kbgg0ni.free-lbv3.idouyinvod.com/v3-web.douyinvod.com/6c057fbe1dc2bf86f48ded76ef966a99/64d995cc/video/tos/cn/tos-cn-ve-15c001-alinc2/920af19403794cc5bc9a96f7fe38d1d3/?a=6383&ch=26&cr=3&dr=0&lr=all&cd=0%7C0%7C0%7C3&cv=1&br=2170&bt=2170&cs=0&ds=3&ft=bvTKJbQQqUuxfdoZPo0OW_EklpPiX-6JdMVJEum5-cvPD-I&mime_type=video_mp4&qs=0&rc=NzQ8Omc2PDk7NzQ0NThlOUBpamZ3eGY6Zjs3PDMzNGkzM0BeY19iMy1gNjMxXzM1Yl5gYSNpamkvcjRvNHBgLS1kLTBzcw%3D%3D&l=202308140942343F873BC04373166D4E5D&btag=e00030000&dy_q=1691977354&ali_redirect_ex_hot=66666800&ali_redirect_ex_beacon=1",
                msg: "成功"
            },
            {
                cover: "https://p6-pc-sign.douyinpic.com/tos-cn-p-0015/189d5556890e4569a87d4a51f8e4b44c_1621843623~tplv-dy-360p.jpeg?biz_tag=pcweb_cover&from=3213915784&s=PackSourceEnum_SEARCH&sc=origin_cover&se=false&x-expires=1693184400&x-signature=ithIQDjQNMfzQgB53smv%2BIOWqAY%3D",
                create_time: 1691715812,
                id: 1,
                mch_id: 62,
                name: "全面招商，合作共赢｜一起向未来",
                num1: 333333333,
                num2: 2222222,
                num3: 111111,
                status: 1,
                update_time: 1691715812,
                url: "http://v26-web.douyinvod.com/de3c91501b472c200940ae1ca379400a/64d99669/video/tos/cn/tos-cn-ve-15/9cfd663c4ddb456bbc8dbf147450e23c/?a=6383&ch=11&cr=3&dr=0&lr=all&cd=0%7C0%7C0%7C3&cv=1&br=993&bt=993&cs=0&ds=6&ft=bvTKJbQQqUuxfdoZPo0OW_EklpPiXZBJdMVJEum5-cvPD-I&mime_type=video_mp4&qs=0&rc=aDtpNDY3NzM6NTY8NDdoaUBpM2ZxbHVqeGxvNTMzNGkzM0BgLjEwMGAyXzQxNDRhXzBiYSNvZGJfL3NsbmlgLS1kLTBzcw%3D%3D&l=202308140949465F07E8A1BE44F36A87DF&btag=e00018000&dy_q=1691977787",
                msg: "成功"
            },
            {
                cover: "https://p6-pc-sign.douyinpic.com/tos-cn-p-0015/189d5556890e4569a87d4a51f8e4b44c_1621843623~tplv-dy-360p.jpeg?biz_tag=pcweb_cover&from=3213915784&s=PackSourceEnum_SEARCH&sc=origin_cover&se=false&x-expires=1693184400&x-signature=ithIQDjQNMfzQgB53smv%2BIOWqAY%3D",
                create_time: 1691715812,
                id: 1,
                mch_id: 62,
                name: "全面招商，合作共赢｜一起向未来",
                num1: 333333333,
                num2: 2222222,
                num3: 111111,
                status: 1,
                update_time: 1691715812,
                url: "http://v26-web.douyinvod.com/de3c91501b472c200940ae1ca379400a/64d99669/video/tos/cn/tos-cn-ve-15/9cfd663c4ddb456bbc8dbf147450e23c/?a=6383&ch=11&cr=3&dr=0&lr=all&cd=0%7C0%7C0%7C3&cv=1&br=993&bt=993&cs=0&ds=6&ft=bvTKJbQQqUuxfdoZPo0OW_EklpPiXZBJdMVJEum5-cvPD-I&mime_type=video_mp4&qs=0&rc=aDtpNDY3NzM6NTY8NDdoaUBpM2ZxbHVqeGxvNTMzNGkzM0BgLjEwMGAyXzQxNDRhXzBiYSNvZGJfL3NsbmlgLS1kLTBzcw%3D%3D&l=202308140949465F07E8A1BE44F36A87DF&btag=e00018000&dy_q=1691977787",
                msg: "成功"
            },
            {
                cover: "https://p6-pc-sign.douyinpic.com/tos-cn-p-0015/189d5556890e4569a87d4a51f8e4b44c_1621843623~tplv-dy-360p.jpeg?biz_tag=pcweb_cover&from=3213915784&s=PackSourceEnum_SEARCH&sc=origin_cover&se=false&x-expires=1693184400&x-signature=ithIQDjQNMfzQgB53smv%2BIOWqAY%3D",
                create_time: 1691715812,
                id: 1,
                mch_id: 62,
                name: "全面招商，合作共赢｜一起向未来",
                num1: 333333333,
                num2: 2222222,
                num3: 111111,
                status: 1,
                update_time: 1691715812,
                url: "http://v26-web.douyinvod.com/de3c91501b472c200940ae1ca379400a/64d99669/video/tos/cn/tos-cn-ve-15/9cfd663c4ddb456bbc8dbf147450e23c/?a=6383&ch=11&cr=3&dr=0&lr=all&cd=0%7C0%7C0%7C3&cv=1&br=993&bt=993&cs=0&ds=6&ft=bvTKJbQQqUuxfdoZPo0OW_EklpPiXZBJdMVJEum5-cvPD-I&mime_type=video_mp4&qs=0&rc=aDtpNDY3NzM6NTY8NDdoaUBpM2ZxbHVqeGxvNTMzNGkzM0BgLjEwMGAyXzQxNDRhXzBiYSNvZGJfL3NsbmlgLS1kLTBzcw%3D%3D&l=202308140949465F07E8A1BE44F36A87DF&btag=e00018000&dy_q=1691977787",
                msg: "成功"
            }


        ]
    },
    login() {
        wx.navigateTo({
            url: "/pages/login/login"
        })
    },
    /**
     * 生命周期函数--监听页面加载
     */
    async onLoad(options) {
        this.setData({
            openid: wx.getStorageSync('openid')
        })
        const res = await appnavapi()
        var arr = res.data.data
        if (res.data.code == 200) {
            for (let i = 0; i < arr.foot_navs.length; i++) {
                arr.foot_navs[i].active = true
            }
            console.log(arr);
            app.globalData.tabBar = arr
            this._getlive()
        } else {
            utils.wxshowtoast("数据请求失败")
        }
        app.editTabBar()
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },
    // 直播页面的数据
    async _getlive() {
        console.log(0);
        if (wx.getStorageSync('openid') == "") {
            return
        }
        const res = await adapi()
        wx.hideLoading(res.data.data)
        // if (res.data.code == 200) {
        //     console.log(res.data.data);
        //     this.setData({
        //       adList: res.data.data
        //     })
        // } else {
        //     // utils.wxshowtoast(res.data.msg)
        // }
    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {
        return {
            title: '分享给你一个页面',
            path: '/pages/index/index',
            imageUrl: '../../img/nologin.png'
        }
    },

    toShare:function (){
        console.log("去风险")
        this.onShareAppMessage()
    }

})
